﻿using GameScoring.ViewModel;

namespace GameScoring
{
    public partial class MainPage : ContentPage
    {
        MainPageModel mode { get; set; }
        public MainPage()
        {
            InitializeComponent();
            this.Loaded += MainPage_Loaded;
            mode = this.BindingContext as MainPageModel;
            mode.EventOpen += Mode_EventOpen;
        }

        private async void Mode_EventOpen(string obj)
        {
            GameInfo gameInfo = new GameInfo();
            gameInfo.openType = 1;
            gameInfo.GameId = obj;
            await Navigation.PushAsync(gameInfo);

        }

        private void MainPage_Loaded(object? sender, EventArgs e)
        {
            mode.LoadData();
        }

        private async void ToolbarItem_Clicked(object sender, EventArgs e)
        {
            GameInfo gameInfo = new GameInfo();
            gameInfo.openType = 0;
            await Navigation.PushAsync(gameInfo);
        }
    }

}
